package jeumpapayment;

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.XYEdges;
import net.rim.device.api.ui.component.BasicEditField;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.PasswordEditField;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;
import net.rim.device.api.ui.decor.BackgroundFactory;
import net.rim.device.api.ui.decor.Border;
import net.rim.device.api.ui.decor.BorderFactory;


public class LoginScreen extends MainScreen{
	private LoginScreen me;
	private final int WIDTH = JeumpaPayment.SCREEN_WIDTH; 
	private final int HEIGHT = JeumpaPayment.SCREEN_HEIGHT;
	
	public LoginScreen(){
		super();
		this.me = this;
		VerticalFieldManager manager = (VerticalFieldManager)getMainManager();
		
//======================================= Draw the background of log in screen =======================================================
		Bitmap bitmap = new Bitmap(WIDTH,HEIGHT);
		Graphics g = Graphics.create(bitmap);
		g.setColor(0x000000);
		g.fillRect(0, 0, WIDTH,HEIGHT);
		//g.setColor(0x4B3D39);
		//g.fillRoundRect(20,70,320,100,30,30); //untuk mengambar round box (20,70,320,200,30,30)
		//g.setColor(0x777474);
		//g.drawRoundRect(20,70,320,200,30,30); // untuk mengambar round box border
		g.drawBitmap(0,0,JeumpaPayment.BANNER.getWidth(),JeumpaPayment.BANNER.getHeight(), JeumpaPayment.BANNER,0,0);
		manager.setBackground(BackgroundFactory.createBitmapBackground(bitmap));
		
//==================================================================================================================================================
	
		
//========================================= Draw the background for Phone and Pin ==========================================================
		
		//Phone number, pin, and email Field
		//set the background
		g.setColor(Color.BLACK);
		g.fillRoundRect(20, 75, 320, 200, 30, 30);
		g.setColor(0xEEC900);
		//g.drawRoundRect(20,75,320,200,30,30); // untuk mengambar round box border
		g.drawLine(20, 280, 340, 280);
		
//===================================================================================================================================================
		
		
//==================================================PHONE NUMBER==============================================================
		
		//Phone number Field
		LabelField insertPhone = new LabelField("No Telp:"){
			
			protected void paint(Graphics g){
				
				g.setColor(0xEEC900); ////Color.FLORALWHITE
				super.paint(g);
			}
		};
		// tentukan letak untuk insert phone number
		insertPhone.setMargin(85,30,0,30);
		
		BasicEditField phoneNumber = new BasicEditField(EditField.FILTER_PHONE);
		phoneNumber.setBackground(BackgroundFactory.createSolidBackground(Color.WHITESMOKE));
		phoneNumber.setPadding(5,5,5,5);
		phoneNumber.setMargin(0,30,0,30);
		phoneNumber.setBorder(BorderFactory.createRoundedBorder(new XYEdges(5,5,5,5),0xFFCC00,Border.STYLE_SOLID));
		//
		
		//add phone number field and input Box
		add(insertPhone);
		add(phoneNumber);
		
//===================================================================================================================================
		

//===================================================SECURITY NUMBER=================================================================		

		//Security Number Field
		LabelField insertSecurityNumber = new LabelField("Kata Sandi:"){
			protected void paint(Graphics g){
				g.setColor(0xEEC900);
				super.paint(g);
			}
		};
		
		insertSecurityNumber.setMargin(5,30,0,30);
		
		PasswordEditField password = new PasswordEditField();
		password.setBackground(BackgroundFactory.createSolidBackground(Color.WHITESMOKE));
		password.setPadding(5,5,5,5);
		password.setMargin(0,30,0,30);
		password.setBorder(BorderFactory.createRoundedBorder(new XYEdges(5,5,5,5),0xFFCC00,Border.STYLE_SOLID));
		
		//add security number field and input box
		add(insertSecurityNumber);
		add(password);
		
//===================================================================================================================================		

		
//================================================ REGISTER BUTTON =====================================================================================
		
		//button field
		
		ButtonField GenerateBarcode = new ButtonField("Generate Barcode ");
		GenerateBarcode.setMargin(10,30,0,30);
		//buttonRegister.setBackground(BackgroundFactory.createSolidBackground(0xF3E88E));
		//XYEdges bt = new XYEdges(5,5,5,5); 
		//buttonRegister.setBorder(BorderFactory.createRoundedBorder(new XYEdges(0,0,0,0),0xF3E88E,Border.STYLE_SOLID));
		//buttonRegister.setBorder(BorderFactory.createBevelBorder(bt));
		GenerateBarcode.setChangeListener(new RegisterButtonHandler());
		
		
		//add button to screen
		add(GenerateBarcode);
	}
	
	public class RegisterButtonHandler implements FieldChangeListener{

		public void fieldChanged(Field field, int context) {
			// TODO Auto-generated method stub
			JeumpaPayment.switchScreen(me,new GenerateBarcodeScreen());
		}
	}
	
}
